﻿

using Bentley.DgnPlatformNET;
using CheccCoverplateCulvertAssemble.Conmmon;
using CheccCoverplateCulvertAssemble.Entity;
using Newtonsoft.Json.Linq;
using System.Data;
using System.Text.RegularExpressions;

namespace CheccCoverplateCulvertAssemble.Rebar;

public class RebarNoHook : RebarBase
{
    public RebarNoHook(ConstructingEntity constructingEntity, string rebarGroupNumber, double diameter, string grades, RebarType rebarType, CurveVector baseLine, double hookDiameter = 0.0, double startRotationAngle = 0, double endRotationAngle = 0)
        : base(constructingEntity, rebarGroupNumber, diameter, grades, rebarType, baseLine, hookDiameter, startRotationAngle, endRotationAngle)
    {
    }
    public override List<(string standardName, string standValue)> CreateStandardECProperty()
    {
        string rebarJsonFilePath =
            System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) +
            @"\rebarConfig.json";
        List<(string standardName, string standValue)> ret = new();
        var cv = this.CreateGuideLineOfRebar();
        var rebarVolume = cv.SumOfLengths() / GeneralHelpers.UorToMeters * Math.PI *
                          Math.Pow(0.5 * this.Diameter * 0.001, 2);
        var rebarLength = cv.SumOfLengths() / GeneralHelpers.UorToMeters;
        ret.Add(("componentName", this._constructingEntity.ToString()));
        ret.Add(("rebarGroup", this.RebarGroupNumber));
        ret.Add(("rebarDiameter", this.Diameter.ToString()));
        ret.Add(("rebarVolume", rebarVolume.ToString()));
        ret.Add(("rebarType", this.RebarType == RebarType.Ribbed ? "带肋" : "光圆"));
        ret.Add(("rebarGrade", this.Grades));
        ret.Add(("rebarLength", rebarLength.ToString()));
        ret.Add(("weightPerMeter", GeneralHelpers.GetWeightPerMeterOfRebar(this.Grades, this.Diameter, rebarJsonFilePath).ToString()));
        ret.Add(("rebarHookLength", null));
        ret.Add(("rebarHookDiameter", null));
        return ret;
    }


    public override CurveVector CreateGuideLineOfRebar()
    {
        return this.BaseLine;
    }
}
